package com.shiku.staticstic.service.admin.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shiku.staticstic.dao.AdminDao;
import com.shiku.staticstic.model.Admin;
import com.shiku.staticstic.service.Response;
import com.shiku.staticstic.service.admin.AdminService;

@Service("adminService")
public class AdminServiceImpl implements AdminService {

	@Autowired
	private AdminDao adminDao;
	
	@Override
	public Response login(String username, String password) {
		Response result = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		//TODO 密码MD5后查询
		map.put("password", password);
		Admin admin = adminDao.get(map);
		if (admin == null) {
			result = new Response("登录失败");
		} else {
			Map<String, String> data = new HashMap<String, String>();
			data.put("id", admin.getId()+"");
			data.put("uname", admin.getUsername());
			result = new Response(data);
		}
		
		return result;
	}

}
